package com.luych.toolbox.common.feign.view.base.service;

import com.luych.toolbox.common.enums.ScriptType;
import com.luych.toolbox.common.feign.FeignView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Comparator;
import java.util.List;

@ApiModel("脚本信息")
public class ScriptView extends FeignView {

    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("类型")
    private ScriptType type;
    @ApiModelProperty("内容")
    private String text;
    @ApiModelProperty("描述")
    private String description;
    @ApiModelProperty("参数")
    private List<ScriptArgView> args;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ScriptType getType() {
        return type;
    }

    public void setType(ScriptType type) {
        this.type = type;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<ScriptArgView> getArgs() {
        return args;
    }

    public void setArgs(List<ScriptArgView> args) {
        this.args = args;
    }

    public void sortArgs() {
        if (this.args == null) return;
        this.args.sort(Comparator.comparing(ScriptArgView::getName));
    }
}
